<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
	 <style type="text/css">
	    .login{width:700px;border:1px solid #ccc;display:none;position:absolute;left:40px;top:50px;z-index:100;background-color: white;}
		.tab_login{width:700px;left:40px}
		.tab_login td{height:50px;line-height:50px;}
	 </style>
    <base href="<%=basePath%>">
    
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	 <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="UI/admins/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="UI/admins/css/main.css"/>
    <script type="text/javascript" src="UI/admins/js/libs/modernizr.min.js"></script>
	
    <script type="text/javascript" src="UI/admins/js/libs/jquery.js"></script>
  </head>
  
  <body>
	<s:if test="message!=null">
		
		<script type="text/javascript">
		$(function(){
			$(".login").show();
			});
		</script>
	</s:if>
    <!--/sidebar-->

        <div class="crumb-wrap">

            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><a class="crumb-name" href="listAllOrdertable">订单管理</a><span class="crumb-step">&gt;</span><span>新增订单</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
            	<s:form action="checkOrdertable" method="post">
                    <table class="insert-tab" width="100%">
                        <tbody>
                            <tr>
                                <th width="150"><i class="require-red">*</i>客户：</th>
                                <td>
                                	<select id="userId" name="userId">
										<option value="">请选择</option>
									</select> 
                                </td>
                            </tr>

                            <tr>
                                <th><i class="require-red">*</i>收货人电话：</th>
                                <td>
                                	<s:textfield id="receivePhone" name="receivePhone"  class="common-text required" onblur="isMobile(this)"></s:textfield>
                                </td>
                                	
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>收货人姓名：</th>
                                <td>
                                	<s:textfield name="receiverName"  class="common-text required" ></s:textfield>
                                </td>
                                	
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>收货人地址：</th>
                                <td>
                                	<s:textfield name="receiverAddress"  class="common-text required" ></s:textfield>
                                </td>
                                	
                            </tr>
                            <tr>
                            	<th><i class="require-red">*</i>商品类别：</th>
                                <td>
                                	<select id="kindId" name="kindId">
										<option value="">请选择</option>
									</select> 
                                
                                <i class="require-red">*</i>商品：
                                
                                	<select id="goodsId" name="goodsId">
										<option value="">请选择</option>
									</select> 
                                </td>
                            </tr>
                            
                            <tr>
                                <th><i class="require-red">*</i>派送员：</th>
                                <td>
                                	<s:select name="disparterId" list="listdisparter" listKey="id" listValue="name"></s:select>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>配送机器的地址：</th>
                                <td>
                                	<select id="address1" name="address1">
										<option value="">请选择</option>
									</select>
									<select id="address2" name="address2">
										<option value="">请选择</option>
									</select>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>是否需要加热：</th>
                                <td>
                                	<s:select id="role" name="heatselect"  list="#{1:'需要加热',2:'无需加热'}">
									</s:select>
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>

                                    <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </s:form>
            </div>
        </div>
	<div class="login">
		<s:form action="addOrdertable" method="post">
			<!--必填，提交给哪个后台文件处理-->
			<table class="tab_login" style="width: 459px; ">
				<caption>
					<h3>订单确认</h3>
				</caption>
				<tr>
					<th width="150">订单号：</th>
					<td><s:property value="ordertable.orderId"/></td>
					<s:hidden name="ordertable.orderId"></s:hidden>
				</tr>
				<tr>
					<th>商家名：</th>
					<td><s:property value="username"/></td>
					<s:hidden name="userId"></s:hidden>
				</tr>
				<tr>
					<th>商品名：</th>
					<td><s:property value="goodsname"/></td>
					<s:hidden name="goodsId"></s:hidden>
				</tr>
				<tr>
					<th>接收人电话：</th>
					<td><s:property value="ordertable.receiverPhone" /></td>
					<s:hidden name="ordertable.receiverPhone"></s:hidden>
				</tr>
				<tr>
					<th>接收人姓名：</th>
					<td><s:property value="ordertable.receiverName" /></td>
					<s:hidden name="ordertable.receiverName"></s:hidden>
				</tr>
				<tr>
					<th>接收人地址：</th>
					<td><s:property value="ordertable.receiverAddress" /></td>
					<s:hidden name="ordertable.receiverAddress"></s:hidden>
				</tr>
				<tr>
					<th>配送员名字：</th>
					<td><s:property value="ordertable.disparter.name"/></td>
					
					<s:hidden name="ordertable.disparter.id"></s:hidden>
				</tr>
				<tr>
					<th>机器地址：</th>
					<td><s:property value="ordertable.machine.machineaddress.name"/></td>
					<s:hidden name="ordertable.machine.id"></s:hidden>
					<s:hidden name="ordertable.machine.machineaddress.id"></s:hidden>
				</tr>
				<tr>
					<th>是否需要加热：</th>
					<td>
					<s:if test="ordertable.heat==false">
					无需加热
					</s:if>
					<s:elseif test="ordertable.heat==true">
					需要加热
					</s:elseif>
					</td>
					<s:hidden name="ordertable.heat"></s:hidden>
				</tr>
				<tr>
					<td><input class="btn btn-primary btn6 mr10" type="submit" name="submit" value="确认" ></td>
					<th><input class="btn btn6" onclick="history.go(-1)" value="返回" type="button"></th>
				</tr>
				
			</table>
		</s:form>
	</div>
	<!--/main-->
  	<script type="text/javascript" language="javascript">
$(document).ready(function(){
	//获取用户
	$.post("getUser.action",function(data){      //data代表服务器端传来的数据
		var jsonObj=eval("("+data+")");                    //封装服务器数据为json对象
		for(var i=0;i<jsonObj.length;i++){
			var $option=$("<option></option>");
			$option.attr("value",jsonObj[i].uid);
			$option.text(jsonObj[i].name);
			$("#userId").append($option);
		}
	});
	//获取货物类别
	$.post("getKind.action",function(data){      //data代表服务器端传来的数据
		var jsonObj=eval("("+data+")");                    //封装服务器数据为json对象
		for(var i=0;i<jsonObj.length;i++){
			var $option=$("<option></option>");
			$option.attr("value",jsonObj[i].kid);
			$option.text(jsonObj[i].kname);
			$("#kindId").append($option);
		}
	});
	$("#userId").change(function(){
		$("#goodsId option[value!='']").remove();
		$("#kindId option[value!='']").remove();
		$.post("getKind.action",function(data){      //data代表服务器端传来的数据
		var jsonObj=eval("("+data+")");                    //封装服务器数据为json对象
		for(var i=0;i<jsonObj.length;i++){
			var $option=$("<option></option>");
			$option.attr("value",jsonObj[i].kid);
			$option.text(jsonObj[i].kname);
			$("#kindId").append($option);
		}
	});
	});
	//根据用户获取货物
	$("#kindId").change(function(){
		$.post("getGoods.action",{uid:$("#userId").val(),kid:$("#kindId").val()},function(data){
			//清空货物
			$("#goodsId option[value!='']").remove();
			var jsonObj=eval("("+data+")");
			if (data=="null"){
				alert("该类别无商品");
				$("#goodsId option[value!='']").remove();
			}else{
				for(var i=0;i<jsonObj.length;i++){
				var $option=$("<option></option>");
				$option.attr("value",jsonObj[i].gid);
				$option.text(jsonObj[i].gname);
				$("#goodsId").append($option);
			}
			}
			
	});
	});
	//获取一级地址
	$.post("getMachineAddressFirst.action",function(data){      //data代表服务器端传来的数据
		var jsonObj=eval("("+data+")");                    //封装服务器数据为json对象
		for(var i=0;i<jsonObj.length;i++){
			var $option=$("<option></option>");
			$option.attr("value",jsonObj[i].mid);
			$option.text(jsonObj[i].mname);
			$("#address1").append($option);
		}
	});
	//获取二级地址
	$("#address1").change(function(){
		$.post("getMachineAddressSecond.action",{mid:$("#address1").val()},function(data){
			//清空二级地址
			if (data=="null"){
				alert("该一级地址无可用自助终端");
			}
			$("#address2 option[value!='']").remove();
			var jsonObj=eval("("+data+")");
			for(var i=0;i<jsonObj.length;i++){
				var $option=$("<option></option>");
				$option.attr("value",jsonObj[i].mid);
				$option.text(jsonObj[i].mname);
				$("#address2").append($option);
			}
		});
	});
	 $(function(){
		     $("#showLogin").click(function(){
			   $(".login").show();
			 });
		  });
	
});
</script> 
<script type="text/javascript">
 function isMobile(object)
            {
            var s =document.getElementById(object.id).value; 
            var reg0 = /^1[3,5,8]\d{9}$/;;
            var my = false;
            if (reg0.test(s))my=true;
                if(s!="")
                {
                    if (!my)
                    {
                       alert('请输入正确的手机号码');
                       object.value="";
                       object.focus();
                    }
                }else{
                	alert('请输入手机号');
                	object.value="";
                       object.focus();
                }
            }
            </script>
  </body>
</html>
